package com.yyq.servlets;

import javax.servlet.ServletContext;

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

public class ApplicationContextHandle {

	private static ApplicationContext ctx = null;

	private ApplicationContextHandle(ServletContext servletContext){
	}
	
	
	public static void init(ServletContext servletContext){
		ctx = WebApplicationContextUtils.getWebApplicationContext(servletContext);
	}
	
	public static Object getBean(String beanName){
		return ctx.getBean(beanName);
	}
	
	public static String[] getBeanNameByType(Class name){
		return ctx.getBeanNamesForType(name);
	}
}
